<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org/">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Dashboard Template for Bootstrap</title>
		<!-- Bootstrap core CSS -->
		<link href="asserts/css/bootstrap.min.css" rel="stylesheet" th:href="@{/webjars/bootstrap/4.2.1/css/bootstrap.min.css}">

		<!-- Custom styles for this template -->
		<link href="asserts/css/dashboard.css" rel="stylesheet" th:href="@{/asserts/css/dashboard.css}">

	</head>

	<body>
        <!--调用抽取的公共页-->
       <div th:replace="commons/bar::topbar"></div>

		<div class="container-fluid">
			<div class="row">
                <!--引入侧边栏-->
				<div th:replace="commons/bar::#sidebar(activeUri='emps')"></div>
				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<h2> <a class="btn btn-sm btn-success" href="/emp" th:href="@{/emp}">添加员工</a></h2>
					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
								<tr>
									<th>#</th>
									<th>姓名</th>
									<th>邮箱</th>
									<th>性别</th>
									<th>生日</th>
									<th>部门</th>
									<th>操作</th>
								</tr>
							</thead>
                            <tbody>
							    <tr th:each="emp:${emps}">
                                    <td th:text="${emp.id}"></td>
									 <td>[[${emp.lastName}]]</td>
									 <td th:text="${emp.email}"></td>
									 <td th:text="${emp.gender}==0?'女':'男'"></td>
									 <td th:text="${#dates.format(emp.birth,'yyyy-MM-dd HH:mm')}"></td>
									 <td th:text="${emp.department.departmentName}"></td>
									 <td>
										 <a class="btn btn-sm btn-primary" th:href="@{/emp/}+${emp.id}">编辑</a>
										 <!--<form th:action="@{/emp/}+${emp.id}" method="post">-->
											 <!--<input type="hidden" name="_method" value="delete">-->
											 <!--<button type="submit" class="btn btn-sm btn-danger">删除</button>-->
										 <!--</form>-->
										 <!--del_url 是自定义属性存放需要删除的员工url地址-->
										 <button th:attr="del_url=@{/emp/}+${emp.id}" class="btn btn-sm btn-danger deletebtn">删除</button>
									 </td>
								</tr>
							</tbody>
						</table>
					</div>
				</main>
				<form id="deleteEmpFrom"  method="post">
				<input type="hidden" name="_method" value="delete">

				</form>
			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
	   <!-- Placed at the end of the document so the pages load faster -->
	   <script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js" th:href="@{/webjars/js/jquery/3.2.1/jquery.min.js}"></script>
	   <script type="text/javascript" src="asserts/js/popper.min.js" th:href="@{/asserts/js/popper.min.js}"></script>
	   <script type="text/javascript" src="asserts/js/bootstrap.min.js" th:href="@{/asserts/js/bootstrap.min.js}" ></script>

	   <!-- Icons -->
	   <script type="text/javascript" src="asserts/js/feather.min.js" th:href="@{/asserts/js/feather.min.js}" ></script>
	   <script>
		   feather.replace()
	   </script>

       <!---->
       <script>
		   $(".deletebtn").click(function () {
		   	    // alert($(this).attr("del_url"))
		   	   //取出按钮中自定义的属性，然后用from提交
               $("#deleteEmpFrom").attr("action",$(this).attr("del_url")).submit();
			   return false
		   });
	   </script>

	</body>

</html>